
# APPID 已在配置中移除,请在参数 Bucket 中带上 APPID。Bucket 由 BucketName-APPID 组成
# 1. 设置用户配置, 包括 secretId，secretKey 以及 Region
# -*- coding=utf-8
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import logging

logging.basicConfig(level=logging.INFO, stream=sys.stdout)

secret_id = 'AKIDITXWK1Kx9AwUyD99k7LMHy4wb7QUb6Yk '      # 替换为用户的 secretId
secret_key = '6zf7MM7pW2HI6ewzoUw85oHXhcIQ9lEX '      # 替换为用户的 secretKey
region = 'ap-beijing'     # 替换为用户的 Region
token = None                # 使用临时密钥需要传入 Token，默认为空，可不填
scheme = 'https'            # 指定使用 http/https 协议来访问 COS，默认为 https，可不填
config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token, Scheme=scheme)
# 2. 获取客户端对象
client = CosS3Client(config)
#
# print(client.__dict__)

# 参照下文的描述。或者参照 Demo 程序，详见 https://github.com/tencentyun/cos-python-sdk-v5/blob/master/qcloud_cos/demo.py

# with open('hello_spring.jpg', 'rb',) as fp:
#     response = client.put_object(
#         Bucket='tracer-1300928241',
#         Body=fp,
#         Key='hello_spring.jpg',
#         StorageClass='STANDARD',
#         EnableMD5=False
#     )
#
# print(response)

